use crate::dao;
use crate::runtime::response::MagicBoxResponse;
use crate::runtime::result::MagicBoxResult;

#[tauri::command(rename_all = "snake_case")]
pub(crate) async fn invoke_component_v2ray_reset_router() -> MagicBoxResult<MagicBoxResponse<()>> {
    let routers = dao::components::v2ray::router::get_all_routers()?;
    for router in &routers {
        if !router.preset {
            dao::components::v2ray::router::remove_router(router.uuid.clone())?;
        }
    }

    Ok(MagicBoxResponse::new_empty_success())
}